// utils/file.ts
export const downloadFile = (url: string, filename: string) => {
    // 创建隐藏的可下载链接
    const a = document.createElement('a')
    a.href = url
    a.download = filename
    a.style.display = 'none'
    document.body.appendChild(a)
    a.click()
    document.body.removeChild(a)

    // fetch(url)
    //   .then(res => res.blob())
    //   .then(blob => {
    //     const blobUrl = window.URL.createObjectURL(blob)
    //     const a = document.createElement('a')
    //     a.href = blobUrl
    //     a.download = filename
    //     document.body.appendChild(a)
    //     a.click()
    //     window.URL.revokeObjectURL(blobUrl)
    //     document.body.removeChild(a)
    //   })
}